package com.tamecode.chapter06.sec2;

import java.beans.IntrospectionException;
import java.beans.PropertyDescriptor;
import java.beans.SimpleBeanInfo;

public class ChartBeanBeanInfo extends SimpleBeanInfo {

    @Override
    public PropertyDescriptor[] getPropertyDescriptors() {
        try {
            // 交 TitlePositionEditor 绑定到 CharBean 的 titlePosition 属性中。
            PropertyDescriptor titlePositionDescriptor = new PropertyDescriptor("titlePosition", ChartBean.class);
            titlePositionDescriptor.setPropertyEditorClass(TitlePositionEditor.class);

            // 将 InverseEditor 绑定到 ChartBean 的 inverse 属性中
            PropertyDescriptor inverseDescriptor = new PropertyDescriptor("inverse", ChartBean.class);
            inverseDescriptor.setPropertyEditorClass(InverseEditor.class);
            return new PropertyDescriptor[] { titlePositionDescriptor, inverseDescriptor };

        } catch (IntrospectionException e) {

        }
        return super.getPropertyDescriptors();
    }
}
